package at.fhooe.mc.master.clc.client.widget;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.VerticalPanel;

public class MessageBox extends DialogBox
{
	private Label label;

	public MessageBox(String header)
	{
		setText(header);

		setAnimationEnabled(true);
		setGlassEnabled(true);

		Button ok = new Button("OK");
		ok.addClickHandler(new ClickHandler()
		{
			public void onClick(ClickEvent event)
			{
				MessageBox.this.hide();
			}
		});

		this.label = new Label();

		VerticalPanel panel = new VerticalPanel();
		panel.setHeight("100");
		panel.setWidth("300");
		panel.setSpacing(10);
		panel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
		panel.add(label);
		panel.add(ok);

		setWidget(panel);

	}

	public MessageBox(String header, String message)
	{
		this(header);
		setMessage(message);
	}

	public void setMessage(String message)
	{
		this.label.setText(message);
	}

//	@Override
//	public void show()
//	{
//		// display popup in center
//		int left = Window.getClientWidth()/ 2;
//        int top = Window.getClientHeight()/ 2;
//        this.setPopupPosition(left, top);
//		super.show();
//	}
	
}
